Skip to content

PHPC-2230: Drop support for PHP 7.2 and 7.3 #1450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 16, 2023

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Jul 31, 2023

PHPC-2230

This drops support for PHP 7.2 and 7.3, along with a bunch of compatibility code.

I've also deleted all tests regarding serialisation on PHP < 7.4 and updated the SKIPIF blocks on those tests that affect PHP 7.4+.

@alcaeus alcaeus requested a review from jmikola July 31, 2023 11:39
@alcaeus alcaeus self-assigned this Jul 31, 2023
Copy link
Member

@jmikola jmikola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted that you're leaving the Serializable implementations in place for now (per PHPC-2248).

I recall there being some EXPECTF patterns that varied by PHP version and decided to search for %r in the tests. That likely doesn't catch everything, but it did turn up quite a bit:

  • %r(argument|parameter)%r and %r(E_NOTICE|E_WARNING)%r date back to 60febd0 and might still be relevant.
  • %r(object|stdClass)%r is pretty recent (6887226) and is probably still relevant.
  • %r[eE]%r was recently introduced in the Int64 tests. I'm not sure if it's was needed for a particular PHP version or platform (e.g. Windows).
  • %r(null|NULL)%r dates back to PHP 5 and can be removed (see: 6512570)
  • int%S and bool%S addresses a difference between PHP 7.2 and 7.3 (98e583b). There may be additional instances of %r(int|integer)%r or %r(bool|boolean)%r.
  • %r(double|float)% addresses a difference between PHP 5 and 7 (see: PHPC-790: Accept integer and floats in Timestamp and UTCDateTime constructors #467 (comment)).
  • %r(0|"0")%r was related to PHP 7.2 (see: 95c4678)
  • %w in set_state tests dates back to HHVM (see: c2fe3b2)

This PR would probably be a good time to address any obsolete patterns in the above list.

@alcaeus
Copy link
Member Author

alcaeus commented Aug 1, 2023

I've cleaned up the following:

  • null|NULL was normalised to null
  • int%S and bool%S were normalised to int and bool
  • double|float was normalised to float
  • The 0 vs. "0" keys in objects were normalised to "0"
  • %w in set_state tests were removed. There is some fancy behaviour going on with a space at the end of the key line when the value is an object, which I've matched using %w to avoid editors automatically removing the trailing whitespace and thus breaking the test.

I've left the others in place for the time being and will check those separately and add comments where possible to indicate when they can be removed.

@alcaeus alcaeus force-pushed the phpc-2230-drop-old-php branch from f269ebd to d33bc7f Compare August 2, 2023 07:58
@alcaeus alcaeus requested a review from jmikola August 2, 2023 07:59
%r\)?%r),
2 =>%w
%r\(object\)? %rarray(
%r\)?%r),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we expect another optional ) character here? I understand an optional (object) cast in the output, but there is already an expected ) to balance array( on the previous line. And there are other closing parens below that balance out the array( instances up top.

I don't think this has anything to do with your previous related comments:

I see you have %r\(object\)? %r above, and the closing paren there is optional. Does that mean that PHP sometimes emits (object array(...))? That doesn't make sense as it wouldn't be valid syntax.

In fact, the %r\(object\)? %r pattern would only match (object or (object) . In that case, it seems like (object) is always present (it's the only valid syntax). So perhaps we should expect (object) for PHP 7.4+.

I tested this in https://3v4l.org/MaXQ3 and (object) is always included in PHP 7.3+. Previous versions would emit stdClass::__set_state(array(...)), which explains the extra closing paren, which is no longer applicable.

And PHP 8.2+ differs slightly by emitting a backslash before class names to make them fully-qualified. This is already accounted for with the %r\\?%r pattern earlier in the EXPECTF block.


Note: this applies to other EXPECTF sections with __set_state() output.

Copy link
Member Author

@alcaeus alcaeus Aug 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good observation, I believe I originally added this in error and then it spread via the usual way of copy/paste.

@alcaeus alcaeus force-pushed the phpc-2230-drop-old-php branch 2 times, most recently from bab167c to 5c195e6 Compare August 4, 2023 15:59
@alcaeus alcaeus force-pushed the phpc-2230-drop-old-php branch from 5c195e6 to e37a313 Compare August 16, 2023 10:57
@alcaeus alcaeus force-pushed the phpc-2230-drop-old-php branch from e37a313 to 45ed3d6 Compare August 16, 2023 11:20
@alcaeus alcaeus merged commit 2ab1e4b into mongodb:master Aug 16, 2023
@alcaeus alcaeus deleted the phpc-2230-drop-old-php branch August 16, 2023 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants